#include "LibSV/sensor.h"
#include <windows.h>
#include <iostream>

int callback(void* ai_img, LibSV::Movimiento* ai_mov)
{
	static LibSV::Movimiento mov;
	mov += *ai_mov;
	std::cout << "\rPan: " << mov.pan << "\tTilt: "  << mov.tilt << "\tRotacion: " << mov.rot << "\tAvance: " << mov.avance;

	return 0;
}

DWORD WINAPI funcThread(LPVOID lpParam)
{
	LibSV::CallbackFn cb = (LibSV::CallbackFn)lpParam;
	if (inicializar(1) == 0)
		activar(cb);

	return 0;
}

int main()
{
	std::cout << "\n\t\t-[ Sensor Visual de movimiento ]-\n\n" << std::flush;

    HANDLE hThread = CreateThread( 0, 0, funcThread, &callback, 0, 0);  
    if (hThread == 0)
        ExitProcess(-1);

    system("pause");
    detener();
    WaitForSingleObject(hThread, INFINITE);
    CloseHandle(hThread);
}